package org.gemstone.panel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import org.come.entity.Goodstable;
import org.come.until.CutButtonImage;
import org.gemstone.btn.GemstoneOperationBtn;
import org.gemstone.mouseListener.CancelMouseListener;

import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;



/**
 * 宝石重铸面板
 *
 * @author Administrator
 *
 */
public class GemstoneOperationAppraisalAndRecastPanel extends JPanel {

    private JLabel recastGemstone // 重铸宝石
            ,
            gemstoneName // 第一颗宝石名
                    ;

    private Goodstable reelectGoods; // 重选类型type

    private GemstoneOperationBtn reacastBtn // 重铸按钮
            ,
            reelectBtn // 重选类型按钮
                    ;

    private JLabel[] gemstoneNumber;// 第一颗宝石,第二颗宝石

    public GemstoneOperationRecastTypePanel gemstoneOperationRecastTypePanel;

    public GemstoneOperationAppraisalAndRecastPanel() {
    		this.setPreferredSize(new Dimension(310, 260));
            this.setOpaque(false);
            this.setLayout(null);
            gemstoneOperationRecastTypePanel = new GemstoneOperationRecastTypePanel();
            this.add(gemstoneOperationRecastTypePanel);
            gemstoneName = new JLabel();
            recastGemstone = new JLabel();
            reacastBtn = new GemstoneOperationBtn("skin/8100226/newbutton/B20.png", 1, UIUtils.COLOR_BTNPUTONG, "重铸",
                    UIUtils.TEXT_HY16, 8);
            reelectBtn = new GemstoneOperationBtn("skin/8100226/button/49.png", 1, UIUtils.COLOR_BTNTEXT, "重选类型",
                    UIUtils.TEXT_FONT, 9);
            gemstoneNumber = new JLabel[2];
            for (int i = 0; i < gemstoneNumber.length; i++) {
                gemstoneNumber[i] = new JLabel();
                gemstoneNumber[i].setOpaque(false);
                gemstoneNumber[i].setBounds(84 + i * 79, 33, 53, 51);
                gemstoneNumber[i].addMouseListener(new CancelMouseListener(i));
                this.add(gemstoneNumber[i]);

            }
            reelectGoods = new Goodstable();

            recastGemstone.setOpaque(false);
            gemstoneName.setOpaque(false);

            gemstoneOperationRecastTypePanel.setVisible(false);

            gemstoneName.setForeground(Color.gray);
            gemstoneName.setFont(new Font("宋体", 0, 13));
            gemstoneName.setHorizontalAlignment(SwingConstants.CENTER);

            gemstoneName.setBounds(84, 12, 53, 13);
            recastGemstone.setBounds(125, 136, 53, 51);
            reelectBtn.setBounds(118, 116, 68, 17);
            reacastBtn.setBounds(121, 210, 59, 24);

            this.add(gemstoneName);
            this.add(recastGemstone);
            this.add(reelectBtn);
            this.add(reacastBtn);


    }

    private ImageIcon iconBack;

    @Override
    protected void paintComponent(Graphics g) {
        // TODO Auto-generated method stub
        super.paintComponent(g);
        	if (iconBack == null) {
                iconBack = new ImageIcon("inkImg/newbackground/B267.png");
            }
            g.drawImage(iconBack.getImage(), 0, 0, 310, 260, this);


    }

    private ImageIcon iconRecastGrayBtn;

    public void changBtnIcon() {
    		if (iconRecastGrayBtn == null) {
                iconRecastGrayBtn = CutButtonImage.getImage("skin/8100226/newbutton/aj1h.png", -1, -1);
            }
            ImageIcon[] iconsRecastBtn = null;
            try {
                iconsRecastBtn = CutButtonImage.cuts("skin/8100226/newbutton/aj1.png");
            } catch (Exception e) {
                // TODO Auto-generated catch block
                System.out.println("缺少素材");
                e.printStackTrace();
            }
            switch (GemstoneOperationMainFrame.getGemstoneOperationMainFrame().getGemstoneOperationMainPanel()
                    .getTypePanel()) {
            case 2:
                reacastBtn.setTypeBtn(8);
                reacastBtn.setText("重铸");
                reacastBtn.setIcons(iconsRecastBtn);
                reelectBtn.setVisible(true);
                reacastBtn.setBtn(-1);
                reelectBtn.setBtn(-1);
                reacastBtn.setIcon(CutButtonImage.getImage("skin/8100226/newbutton/aj1h.png", 59, 24));
                reelectBtn.setIcon(CutButtonImage.getImage("skin/8100226/button/39.png", 68, 17));
                recastGemstone.setIcon(null);
                gemstoneName.setText("主宝石");
                break;
            case 3:
                reacastBtn.setTypeBtn(10);
                reacastBtn.setText("鉴定");
                reacastBtn.setIcons(iconsRecastBtn);
                reacastBtn.setIcon(CutButtonImage.getImage("skin/8100226/newbutton/aj1h.png", 59, 24));
                reacastBtn.setBtn(-1);
                reelectBtn.setVisible(false);
                recastGemstone.setIcon(null);
                gemstoneName.setText("奇异石");
                break;

            default:
                break;
            }

    }

    public JLabel getRecastGemstone() {
        return recastGemstone;
    }

    public void setRecastGemstone(JLabel recastGemstone) {
        this.recastGemstone = recastGemstone;
    }

    public JLabel getGemstoneName() {
        return gemstoneName;
    }

    public void setGemstoneName(JLabel gemstoneName) {
        this.gemstoneName = gemstoneName;
    }

    public GemstoneOperationBtn getReacastBtn() {
        return reacastBtn;
    }

    public void setReacastBtn(GemstoneOperationBtn reacastBtn) {
        this.reacastBtn = reacastBtn;
    }

    public GemstoneOperationBtn getReelectBtn() {
        return reelectBtn;
    }

    public void setReelectBtn(GemstoneOperationBtn reelectBtn) {
        this.reelectBtn = reelectBtn;
    }

    public JLabel[] getGemstoneNumber() {
        return gemstoneNumber;
    }

    public void setGemstoneNumber(JLabel[] gemstoneNumber) {
        this.gemstoneNumber = gemstoneNumber;
    }

    public ImageIcon getIconBack() {
        return iconBack;
    }

    public void setIconBack(ImageIcon iconBack) {
        this.iconBack = iconBack;
    }

    public ImageIcon getIconRecastGrayBtn() {
        return iconRecastGrayBtn;
    }

    public void setIconRecastGrayBtn(ImageIcon iconRecastGrayBtn) {
        this.iconRecastGrayBtn = iconRecastGrayBtn;
    }

    public Goodstable getReelectGoods() {
        return reelectGoods;
    }

    public void setReelectGoods(Goodstable reelectGoods) {
        this.reelectGoods = reelectGoods;
    }

    public GemstoneOperationRecastTypePanel getGemstoneOperationRecastTypePanel() {
        return gemstoneOperationRecastTypePanel;
    }

    public void setGemstoneOperationRecastTypePanel(GemstoneOperationRecastTypePanel gemstoneOperationRecastTypePanel) {
        this.gemstoneOperationRecastTypePanel = gemstoneOperationRecastTypePanel;
    }

}
